<template>
    <div>
        <div>
            <van-nav-bar title="订单详情" left-text="返回" left-arrow @click-left="onClickLeft" />
                <div>
                    <van-card :price="this.goodInfo.goodPrice"  :title="this.goodInfo.goodName" :thumb="this.goodInfo.goodCover" @click="toGoodInfo(goodInfo.goodId)" />
                </div>
        </div>
        <van-submit-bar :price="this.goodInfo.goodPrice*100" currency="积分"  button-text="提交订单" @submit="onSubmit()" />
    </div>
       
</template>

<script>
import axios from 'axios'
export default {
    data() {
        return {
            goodInfo: {},
            goodId: '',
            orderId:''
        }
    },
    methods: {
        findShopsById() {
            this.$axios.post('http://localhost:7000/shop/findGoodByGoodId', { 'goodId': this.goodId }).then(res => {
                this.goodInfo = res.data.data;

            });
        },
        onClickLeft() {
            this.$router.push({ name: "shopInfo", params: { id: this.goodId } });
        },
        toGoodInfo(goodId) { 
            this.$router.push({ name: "shopInfo", params: { id: goodId } });
        },
        onSubmit() { 
            this.$axios.post('http://localhost:7000/shop/findScore', { totalMoney: this.goodInfo.goodPrice}).then(res => {
                if (res.data.code == 0) {
                    alert("积分不足")
                } else { 
                    this.$router.push({ name: "pay", params: { totalMoney: this.totalMoney,id:this.goodId,orderId:this.orderId } });
                }

            });
        }
    },
    //生命周期 - 创建完成（访问当前this实例）
    created() {
        
    },
    //生命周期 - 挂载完成（访问DOM元素）
    mounted() {
        this.goodId = this.$route.params.id;
        this.orderId = this.$route.params.orderId;
        this.findShopsById();
    }
}
</script>
<style scoped>
/* @import url(); 引入css类 */

</style>